#pragma once
#include <iostream>
template<class K, class V>
class map {
public:
	struct MapKeyOfT
	{
		const K& operator()(const pair<K, V>& key)
		{
			return key.first;
		}
	};
	typedef typename RBTree<K, pair<const K, V>, MapKeyOfT>::Iterator iterator;
	typedef typename RBTree<K, pair<const K, V>, MapKeyOfT>::ConstIterator const_iterator;

	iterator begin()
	{
		return _t.Begin();
	}

	iterator end()
	{
		return _t.End();
	}

	const_iterator begin() const
	{
		return _t.Begin();
	}

	const_iterator end()  const
	{
		return _t.End();
	}

	pair<iterator, bool> insert(const pair<K, V>& kv)
	{
		return _t.Insert(kv);
	}

	V& operator[](const K& key)
	{
		pair<iterator, bool> ret = insert({ key, V() });
		return ret.first->second;
	}

	void Iorder();
    
private:
	RBTree<K, pair<const K, V>, MapKeyOfT> _t;
};